from algorithm import *
# from catchObj.Stocks import Stocks
from pdStocks import PdStocks
import multiprocessing


import pandas as pd
def ceshi():
    allStocks = [1,2,3,4]
    pool = multiprocessing.Pool(processes=12)
    for stock in allStocks:
        print(stock)
        # pool.apply_async(task,stocks)

def task(code):
    daily = PdStocks.getDaily('000001.SZ')
    KDJ(daily)
    tt = daily['k']-daily['d']
    tt.rolling(window=2).apply(getPoint)

def getPoint(x):
    if x.iloc[5]<0 and x.iloc[6]>0:
        return 1
    else:
        return 0


ceshi()

def wokao(x):
    print(type(x))
    return x.mean()

def ceshi2(x):
    print(x[1])

# d = {'one': pd.Series([i for i in range(0,9)]),
#     'two': pd.Series([i for i in range(10,19)]),
#     'three': pd.Series([i for i in range(10,19)]),
#     'four': pd.Series([i for i in range(10,19)])}
# df = pd.DataFrame(d)
# rr = df.rolling(window=4,axis=1).apply(wokao,raw = True)
# # tt = df['one']-df['two']
# # tt.rolling(window=2).apply()
# print(rr)
